<!DOCTYPE html>
<html>
<body>

<script type="text/javascript">
gettables(1);

function initCaptionHover(){
  $('.demo').captionHover({
    fx: 'sophie'
  });
}


/*实现锚点功能  点击之后跳转到虚拟身份关系图*/
function moveToMain(index,account,virtualidentity){
    addBeChoose(index);
    $(".account").val(account);
    $("#fontid").html(account);
}

function gettables(num) {
    var flag = num == null?1:num;
    $.ajax({
        type: "POST",
        url: "/virtual/getTableShow/"+flag,
        data: "",
        async: false,
        dataType: 'json',
        success: function(data) {
            $(".prev_button").remove();
            $(".next_button").remove();
             if(data.list.length>0){
                 var str=gethtml(data.list);
                 $(".content-inner").html(str);
                 setTaskListHtml(data);
                 initCaptionHover();
                 addBeChoose(0);
             }else {

             }
        }
    });
    

}


function gethtml(result) {
    var str ="";
    if (result.length>0){
        for (var i=0;i<result.length;i++){
            str += "<div class=\"content-inner-task\" onclick=\"moveToMain("+i+","+result[i].account+",'"+result[i].virtualidentity+"')\" style=\"background-image: url(../img/index/about-bg.jpg);\">" +
                "<figure class=\"demo\" style=\"width:100%\">" +
                "<figcaption style=\"height:150px;\">" +
                "<div style=\"margin-top:40px;\"><h4>" +
                "<span style='font-size:15px;'><@spring.message 'upload.phone' />: "+result[i].account+"</span><br><br>" +
                "</h4>" +
                "</div>" +
                "<p class=\"description\"><@spring.message 'upload.import' /></p>" +
                "</figcaption>" +
                "</figure>" +
                "</div>";
        }
        $("#fontid").html(result[0].account);
    }
    if(result.length < 7){
        for (var j =0;j<7-result.length;j++){
            str += "<div class=\"content-inner-task\" style=\"background-image: url(../img/index/about-bg.jpg);\">" +"</div>";
        }
    }
    
    
    return str;
}



/*构建前台界面*/
function setTaskListHtml(allData){
    var prePage = allData.prePage;
    var nextPage = allData.nextPage;
    var hasPreviousPage = allData.hasPreviousPage;
    var hasNextPage = allData.hasNextPage;
    if (hasPreviousPage) {
        $(".content-inner").append("<div class='prev_button' onclick='gettables("+prePage+");'></div>");
    }

    if (hasNextPage) {
        $(".content-inner").append("<div class='next_button' onclick='gettables("+nextPage+");'></div>");
    }
}

/*任务栏被选中*/
function addBeChoose(index){
    $(".content-inner-task").removeClass("taskBeChoose");
    $(".content-inner-task:eq("+index+")").addClass("taskBeChoose");
}
</script>

</body>
</html>
